﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    DAO_User dao_user = new DAO_User();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
    protected void btnDangKy_Click(object sender, EventArgs e)
    {
        User user = new User();
        user.UserName = txtTenNguoiDung.Text;
        user.Account = txtTenDN.Text;
        user.Pass = txtMatKhau.Text;
        user.Email = txtEmail.Text;
        user.Phone = txtDienThoai.Text;
        user.Address = txtDiaChi.Text;

        if (dao_user.CheckExistUser(user))
        {
            txtThongBao.Text = "Người dùng đã tồn tại";
        }
        else
        {
            if (txtMatKhau.Text == txtMatKhau1.Text)
            {
                int kq = dao_user.InsertUser(user);
                if (kq > 0)
                {
                    txtThongBao.Text = "Đăng ký thành công";
                }
                else
                {
                    txtThongBao.Text = "Insert khong thanh cong";
                }
            }
            

        }

        String UserName = txtTenDN.Text;
    }
}